import 'package:flutter/material.dart'; // fim简便写法
import 'res/listData.dart';

//  GridView

void main() {
  runApp(MyApp());
}

// 基本结构
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('container  text')),
        body: HomeContent(),
      ),
    );
  }
}

class HomeContent extends StatelessWidget {

  // 01 Row 组件
  @override
  // Widget build(BuildContext context) {
  //   // return IconContainer(Icons.search, color: Colors.blue);
  //   return Container(
  //     height: 800.0,
  //     width: 350.0,
  //     color: Colors.pink,
  //     child: Row(
  //       mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  //       crossAxisAlignment: CrossAxisAlignment.start,
  //       children: <Widget>[
  //           IconContainer(Icons.search, color: Colors.blue),
  //           IconContainer(Icons.home, color: Colors.orange),
  //           IconContainer(Icons.select_all, color: Colors.red)
  //         ],
  //     ),
  //   );
  // }

  // 02 Column 组件
  @override
  Widget build(BuildContext context) {
    // return IconContainer(Icons.search, color: Colors.blue);
    return Container(
      height: 800.0,
      width: 350.0,
      color: Colors.pink,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        crossAxisAlignment: CrossAxisAlignment.end,
        children: <Widget>[
            IconContainer(Icons.search, color: Colors.blue),
            IconContainer(Icons.home, color: Colors.orange),
            IconContainer(Icons.select_all, color: Colors.red)
          ],
      ),
    );
  }

}

class IconContainer extends StatelessWidget {
  double size = 32.0;
  Color color = Colors.red;
  IconData icon;
  IconContainer(this.icon, {this.color, this.size});
  @override
  Widget build(BuildContext context) {
    return Container(
      height: 100.0,
      width: 100.0,
      color: this.color,
      child: Center(
        child: Icon(
          this.icon,
          size: this.size,
          color: Colors.white,
        ),
      ),
    );
  }
}
